/*
 * @Author: 黑白灰01 3193273703@qq.com
 * @Date: 2025-09-01 13:38:11
 * @LastEditors: 黑白灰01 3193273703@qq.com
 * @LastEditTime: 2025-09-01 15:59:09
 * @FilePath: /hei-oa/src/user/user.controller.ts
 * @Description: 用户控制器
 */
import { Controller, Get, Post, Body, Patch, Param, Delete, Query } from '@nestjs/common';
import { UserService } from './user.service';
import { CreateUserDto } from './dto/create-user.dto';
import { UpdateUserDto } from './dto/update-user.dto';
import { ApiBody, ApiTags,ApiOkResponse,ApiQuery } from '@nestjs/swagger';
import { PaginationResponseDto } from 'src/common/dto/pagination-response.dto';
import { PaginationDto } from 'src/common/dto/pagination.dto';
import { User } from './entities/user.entity';
import { UserVo } from './dto/user.vo';

@ApiTags('用户管理')
@Controller('user')
export class UserController {
  constructor(private readonly userService: UserService) {}

  @Post('add')
  @ApiBody({ type: CreateUserDto })
  create(@Body() createUserDto: CreateUserDto) {
    return this.userService.create(createUserDto);
  }
    /**
   * @description: 用户列表
   * @param {*}
   * @return {*}
   */
    @Get()
    @ApiOkResponse({
      type: PaginationResponseDto,
      description: '用户分页列表',
    })
    @ApiQuery({ type: PaginationDto })
    async list(
      @Query() paginationDto: PaginationDto,
    ): Promise<PaginationResponseDto<UserVo>> {
      return this.userService.paginate(paginationDto);
    }

  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.userService.findOne(+id);
  }

  @Patch(':id')
  update(@Param('id') id: string, @Body() updateUserDto: UpdateUserDto) {
    return this.userService.update(+id, updateUserDto);
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.userService.remove(+id);
  }
}
